package DataStructureAndAlgorithm.AcWing_每日一题.双指针;
//破环成链，双指针
//链接：https://www.acwing.com/problem/content/3813/
import java.util.Scanner;

class AcWing_3810{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();

        for (int k = 0; k < t; k++){
            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++){
                nums[i] = in.nextInt();
            }

            int res = 0;
            int cnt = 0;
            for (int i = 0; i < n; i++){
                if (i == n - 1 && nums[i] == 1){
                    cnt++;
                    int j = 0;
                    while (j < n && nums[j] == 1){j++;cnt++;}
                }else if (nums[i] == 1)cnt++;
                else cnt = 0;
                res = Math.max(res,cnt);
            }
            System.out.println(res);
        }

        in.close();
    }
}